package org.streets.workflow.engine;

import java.util.Date;
import java.util.List;

import org.streets.workflow.engine.entities.ProcessVariant;
import org.streets.workflow.model.WFProcess;


/**
 * 流程实例接口<br>
 * 对流程实例的状态字段作如下规定：小于5的状态为“活动”状态，大于等于5的状态为“非活动”状态。<br>
 * 活动状态包括：INITIALIZED,RUNNING,SUSPENDED<br>
 * 非活动状态包括：COMPLETED,CANCELED
 * @author 非也,nychen2000@163.com
 * @author lifw555@gmail.com
 */
public interface IProcessInstance {
    
    public static final int INITIALIZED = 0;
    
    public static final int RUNNING = 1;
    
    public static final int COMPLETED = 7;
    
    public static final int CANCELED = 9;

    /**
     * 主键
     * @return
     */
    public String getId();

    /**
     * 流程实例的name（与流程定义的name相同）
     * @return
     */
    public String getName();

    /**
     * 流程定义的id
     * @return
     */
    public String getDefinitionId();

    /**
     * 流程定义的Version
     * @return
     */
    public Integer getVersion();

    /**
     * 流程实例的状态
     * @return
     */
    public Integer getState();

    /**
     * 流程实例创建者ID
     * @return
     */
    public String getCreatorId();


    /**
     * 返回流程实例的创建时间
     * @return 流程实例的创建时间
     */
    public Date getCreatedTime();

    /**
     * 返回流程实例的启动时间，即执行IProcessInstance.run()的时间
     * @return
     */
    public Date getStartedTime();

    /**
     * 返回流程实例的结束时间
     * @return
     */
    public Date getEndTime();

    /**
     * 返回流程实例的到期时间
     * @return
     */
    public Date getExpiredTime();

//    /**
//     * wangmj 获取流程实例变量的值.<br>
//     * Get the process instance variable,return null if the variable is not existing .
//     * @param name the name of the variable
//     * @return the value of the variable. It may be Integer,String,Boolean,java.util.Date or Float
//     */
//    public Object getProcessInstanceVariable(String name);
//
//    /**
//     * Save the process instance variable.If there is a variable with the same name ,it will be updated.
//     * @param name
//     * @param var The value of the variable. It may be Integer,String,Boolean,java.util.Date or Float
//     */
//    public void setProcessInstanceVariable(String name, Object var);
//
//    /**
//     * Get all the process instance variables. the key of the returned map is the variable's name
//     * @return 
//     */
//    public Map<String ,Object> getProcessInstanceVariables();
//
//    /**
//     * update the process instance variables batched.
//     * @param vars
//     */
//    public void setProcessInstanceVariables(Map<String ,Object> vars);
//
//    /**
//     * return the corresponding workflow process.
//     * @return
//     */
//    public WFProcess getModel() throws WorkflowException;
    
    /**
     * 
     * @param name
     * @return
     */
    public Object getVariable(String name);
    /**
     * 
     * @param name
     * @param value
     */
    public void setVariable(String name, Object value);
    /**
     * 获取流程实例的变量
     * @return
     */
    public List<ProcessVariant> getVariables();
    /**
     * 是否挂起
     * @return
     */
    public Boolean isSuspended();
    /**
     * get the parent process instance's id , null if no parent process instance.
     * @return
     */
    public String getParentId();

    /**
     * get the parent taskinstance's id ,null if no parent taskinstance.
     * @return
     */
    public String getParentTaskId();
    /**
     * 
     * @return
     */
    public WFProcess getModel();

}
